<template>
	<view class="content">
		<view class="list-container">
			<view class="shenhe-list clear">
				<text class="left input_text" >
					昵称
				</text>
				<input type="text" placeholder="请输入昵称" v-model="nicheng" placeholder-style="font-size:30rpx;color:#999999" class="no_border_input left" />
			</view>	
		</view>	
			
		<button class="big_button baocun-btn"  @tap="change()" style="background:#FFFFFF;border: 1px solid #1e99ff;color: #1e99ff;">
			保存
		</button>
	</view>
</template>

<script>
	import httpPath from '@/static/js/path.js';
		import {getlogin} from '@/static/js/login.js';
		import {fmoney} from '@/static/js/login.js';
		export default {
			data() {
				return {
					user:{},//用户登录信息
					nicheng:"",//昵称
				}
			},
			onLoad() {
				
	            this.user = getlogin();
				if(!this.user.islogin){
					uni.showModal({
					   showCancel:false,
					   content:"您还没有登录，请登录"
					})
					uni.navigateTo({
						url:"../public/login"
					})
				}	
				this.getinfo()
			},
			methods: {
				getinfo(){//获取客户端首页信息
					uni.request({
						url: httpPath.filePath+'/api.php/index/member/member_info/',
						method:'POST',
						header:{'content-type':'application/x-www-form-urlencoded'},
						data: {member_id:this.user.member_id},
						success: (res) => {
							if(res.data.code=="200"){	
								this.nicheng=res.data.result.nickname	
							}   
						}
					});
					
				},
				change(){//获取客户端首页信息
				    if(this.nicheng==""||this.nicheng==null){
						uni.showModal({
							showCancel:false,
							content:"请填写昵称"
						})
						return false;
					}
					uni.request({
						url: httpPath.filePath+'/api.php/index/member/change_nickname/',
						method:'POST',
						header:{'content-type':'application/x-www-form-urlencoded'},
						data: {member_id:this.user.member_id,nickname:this.nicheng},
						success: (res) => {
							if(res.data.code=="200"){
								uni.showModal({
									showCancel:false,
									content:"修改成功"
								})
								uni.navigateBack()
							}else{
								uni.showModal({
									showCancel:false,
									content:res.data.message
								})
							}
							   
						}
					});
					
				}
	          
			}
		}

</script>

<style>
	@import "../../colorui/main.css";
	page{background: #FFFFFF;}
	.hetong-list image{width: 100%;height: 100%;}
	.shenhe-text1{line-height: 70rpx!important;color: #323232; }
	/* .edit_con{padding: 10px 0px;} */
</style>
